/**
 * @ClassName ArrayDemo01
 * @Description 使用学生数组，存储三个学生对象
 * @Author Li
 * @Date 2022/8/1 8:36
 * @ModifyDate 2022/8/1 8:36
 * @Version 1.0
 */
public class ArrayDemo01 {
    public static void main(String[] args) {
        // 创建学生数组
        Student[] students = new Student[3];

        // 创建学生对象
        Student stu1 = new Student("王二",22);
        Student stu2 = new Student("张三",23);
        Student stu3 = new Student("李四",24);

        // 把学生对象作为元素赋值给学生数组
        students[0] = stu1;
        students[1] = stu2;
        students[2] = stu3;

        // 遍历学生数组
        for (int i = 0; i < students.length; i++) {
            Student stu = students[i];
            System.out.println(stu.getName() + "的年龄：" + stu.getAge());
        }
    }
}
